/**
 * 
 */
package com.dao.account.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.dao.account.AccountDAO;
import com.domain.account.AccountDO;

/**
 * @author lidian
 * 
 */
public class AccountDAOImpl extends SqlMapClientDaoSupport implements
		AccountDAO {

	public void selectAccountById(AccountDO accountDO) {
		getSqlMapClientTemplate()
				.delete("selectAccountById", accountDO.getId());
	}

	public List selectAllAccounts() {
		return getSqlMapClientTemplate().queryForList("selectAllAccounts");
	}

	public int deleteAccountById(AccountDO accountDO) {
		return getSqlMapClientTemplate().delete("deleteAccountById",
				accountDO.getId());
	}

	public int insertAccount(AccountDO accountDO) {
		try {
			getSqlMapClientTemplate().insert("insertAccount", accountDO);
		} catch (DataAccessException e) {
			e.printStackTrace();
			return 0;
		}
		return 1;
	}

	public int updateAccount(AccountDO accountDO) {
		return getSqlMapClientTemplate().update("updateAccount ", accountDO);
	}

}
